package com.LC.DAO;

import com.LC.Entity.CheckItem;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

@Mapper
public interface CheckItemDAO {
    @Insert("insert into t_checkitem(code,name,sex,age,price,type,remark,attention) values (#{code},#{name},#{sex},#{age},#{price},#{type},#{remark},#{attention})")
    public void add(CheckItem checkItem);

    @Select("<script>" +
            "select * from t_checkitem" +
            "<if test = 'value != null and value.length > 0'>" +
            "where code = #{value} or name = #{value}" + "</if>" +
            "</script>"
    )
    public Page<CheckItem> findPage(String queryString);

    @Select("select count(*) from t_checkgroup_checkitem where checkitem_id = #{id}")
    public int itemInCheckGroup(int id);


    @Delete("delete from t_checkitem where id = #{id}")
    public void deleteById(int id);

    @Select("select * from t_checkitem where id = #{id}")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "code",property = "code"),
            @Result(column = "name",property = "name"),
            @Result(column = "sex",property = "sex"),
            @Result(column = "age",property = "age"),
            @Result(column = "price",property = "price"),
            @Result(column = "type",property = "type"),
            @Result(column = "attention",property = "attention"),
            @Result(column = "remark",property = "remark")
    })
    public CheckItem itemById(int id);

    @Update("update t_checkitem set code = #{code},name=#{name},sex=#{sex},age=#{age},price=#{price},type=#{type}," +
            "attention=#{attention},remark=#{remark} where id = #{id}")
    public void newItemData(CheckItem checkItem);
}
